<script setup lang="ts">
import { reactive } from 'vue'
import { Message, sleep, useLoading } from '@idmy/core'
import { Modal, ModalButton } from '#/modal'
import Update from './Create.vue'
const model = reactive<any>({})

const [onOk, loading] = useLoading(async () => {
	await sleep(1000)
	Message.success('提交成功')
	await Modal.ok(model, 123)
})
Modal.startCountdown(10, () => {
	Message.error('提交失败')
})

const onCancel = (inModal: boolean) => {}

const onUpdate = () => {
	Modal.b.open({
		component: Update,
		position: 'right',
		closable: true,
		title: '更新',
	})
}
</script>

<template>
	<a-form layout="vertical" :model="model" @finish="onOk()">
		<a-form-item label="申请说明" name="remark" required>
			<a-textarea :auto-size="{ minRows: 4 }" v-model:value="model.remark" />
		</a-form-item>
		<ModalButton :loading="loading" @cancel="onCancel"></ModalButton>
		<a-button type="primary" @click="onUpdate()">创建</a-button>
	</a-form>
</template>

<style scoped></style>
